package jp.co.redfox.archclub.poker.hand.comparable;

import java.util.List;

import jp.co.redfox.archclub.poker.Card;
import jp.co.redfox.archclub.poker.Hand;

public class OnePairComparator implements HandComparator {

    @Override
    public int compare(Hand myHand, Hand rivalHand) {
        List<Card> myCards = myHand.getCards();
        List<Card> rivalCards = rivalHand.getCards();
        // phase 1 . ２ペア文字列を比較する
        Card myPair = getPairCard(myCards);
        Card rivalPair = getPairCard(rivalCards);
        if (myPair.strength() > rivalPair.strength())

        return 0;
    }

    private Card getPairCard(List<Card> cards) {
        Card pair = null;
        for (int firstIndex = 0; firstIndex < 4; firstIndex++)
            for (int secondIndex = 1; secondIndex < 5; secondIndex++)
                if (cards.get(firstIndex).getNumber().equals(cards.get(secondIndex).getNumber()))
                    cards.get(firstIndex).getSuits();
                    pair = cards.get(firstIndex);
        return pair;
    }
}